<template>
  <div>
       <div class="head"><strong>首页</strong> > 订单管理 > 订单列表</div>
       <el-card>
           <el-row :gutter="20">
        <el-col :span="6">
          <el-input
            placeholder="请输入内容"
            v-model="querryinfo.query"
            clearable
            @clear="getorderlist"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              @click="getorderlist"
            ></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table
      :data="orderlist"
      style="width: 100%"
      border
      stripe
       class="tables"
      >
      <el-table-column
       type='index'
        >
      </el-table-column>
      <el-table-column
        prop="order_number"
        label="订单编号"
        width="600">
      </el-table-column>
      <el-table-column
        prop="order_price"
        label="订单价格(元)"
        width="120">
      </el-table-column>
      <el-table-column
        prop="pay_status"
        label="是否付款"
        width="120">
        <template slot-scope="scope">
             <el-tag type='danger' v-if="scope.row.pay_status==0">未付款</el-tag>
       <el-tag type='success' v-else>已付款</el-tag>
        </template>

      </el-table-column>
     
      <el-table-column
        prop="is_send"
        label="是否发货"
        width="180">
      </el-table-column>
      <el-table-column
        prop="create_time"
        label="下单时间"
        width="230">
        <template slot-scope="scope">
              {{scope.row.create_time|dateFormat}}
        </template>
      </el-table-column>
       <el-table-column
        label="操作"
        >
        <template slot-scope="scope">
                <el-button
                  type="primary"
                  icon="el-icon-edit"
                  @click="doy(scope.row)"
                  ></el-button
                >
                <el-button
                  
                  icon="el-icon-location-outline"
                  class="bts"
                  @click="fgg(scope.row.order_id)"
                  ></el-button
                >
              </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="querryinfo.pagenum"
        :page-sizes="[1, 3, 5, 7]"
        :page-size="querryinfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
       </el-card>
       <el-dialog
  title="修改地址"
  :visible.sync="dialogVisible"
  width="50%"
  @close='fol'
  >
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" >
   <el-form-item label="省市区/县">
       <el-cascader
            v-model="ruleForm.adress"
            :options="addre"
            :props="sol"
            style="width: 40%"
            clearable
          ></el-cascader>
  </el-form-item>
  <el-form-item label="详细地址" prop="adress2">
    <el-input v-model="ruleForm.adress2"></el-input>
  </el-form-item>
  </el-form>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click='htt'>确 定</el-button>
  </span>
</el-dialog>
 <el-dialog
  title="修改地址"
  :visible.sync="dialog"
  width="50%"
  @close='fol'
  >
  <span>????</span>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialog = false">取 消</el-button>
    <el-button type="primary" @click="dialog = false">确 定</el-button>
  </span>
</el-dialog>
  </div>
</template>

<script>
import addre from './citydata'


export default {
  created() {
    this.getorderlist()
  },
  data() {
    return {
        dialog:false,
       gop:'',
         sol: {
        expandTrigger: 'hover',
        label: 'label',
        value: 'value',
        children: 'children',
        },
        addre:addre,
        ruleForm:{
            address:[],
            adress2:'',
           
           
        },
        rules:{
            adress: [
          {
            message: '请输入分类名称',
            trigger: 'blur',
          },],
           adress2:[
          {
            required: true,
            message: '请输入分类名称',
            trigger: 'blur',
          },
        ],
        },
      dialogVisible: false,
      total: 0,
      querryinfo: {
        query: '',
        pagenum: 1,
        pagesize: 7,
      },
      orderlist: [],
    }
  },
  methods: {
    async getorderlist() {
      const { data: res } = await this.$http.get('orders', {
        params: this.querryinfo,
      })
      if (res.meta.status !== 200) {
        return this.$message.error(res.meta.msg)
      }
      console.log(res)
      this.$message.success(res.meta.msg)
      this.orderlist = res.data.goods
      this.total = res.data.total
      //console.log(this.querryinfo);
    },
    hot() {},
    handleSizeChange(mk) {
      this.querryinfo.pagesize = mk
      this.getorderlist()
    },
    handleCurrentChange(ms) {
      this.querryinfo.pagenum = ms
      this.getorderlist()
    },
    doy(id) {
      this.dialogVisible = true
      console.log(id);
      this.gop=id.order_id
    },
    fol(){
        this.$refs.ruleForm.resetFields()
    },
    htt(){
        this.$refs.ruleForm.validate(async valid =>{
            if(!valid)return
           this.$message.success('修改成功')
           this.dialogVisible=false
        })
    },
  async  fgg(){
      const{data:res}=await this.$http.get(`/kuaidi/`)
      if(res.meta.status!==200){
          return this.$message.error('失败')
      }
      this.$message.success(res.meta.msg)
        //this.dialog=true
    }
  },
}
</script>

<style lang='less' scope>
.head {
  margin-left: 20px;
  margin-top: 25px;
  font-size: 14px;
  margin-bottom: 20px;
}
.bts {
  background-color: green !important;
  color: white !important;
}
</style>